package run.siyuan;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.Collections;

/**
 * @author sioyuan
 */
public class GeneratorMain {
    public static void main(String[] args) {
        //连接数据库
        FastAutoGenerator.create("jdbc:mysql://172.30.86.138:40013/xiandaizhihuigongyinglian_db_zhoushengfeng?useUnicode=true&characterEncoding=utf8&useAffectedRows=true&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull"
                        , "xdzhgyl_zhoushengfeng"
                        , "Xdzhgyl@2022")
                .globalConfig(builder -> {
                    builder //.author("") // 设置作者
                            //.enableSwagger() // 开启 swagger 模式
                            .fileOverride() // 覆盖已生成文件
                            .outputDir("E:\\IdeaProjects\\siyuan\\siyuan-generator2\\src\\main\\java\\run\\siyuan\\generator2"); // 设置实体类、mapper、service的生成路径
                })
                .packageConfig(builder -> {
                    builder.parent("a") // 设置父包名
                            .moduleName("a") // 设置父包模块名                              // 设置mapper映射文件的生成路径
                            .pathInfo(Collections.singletonMap(OutputFile.mapperXml, "E:\\IdeaProjects\\siyuan\\siyuan-generator2\\src\\main\\java\\run\\siyuan\\mapper"));
                })
                .strategyConfig(builder -> {
                    builder.addInclude("scgk_record_form_template")              // 设置操作的表名
                            .addInclude("scgk_record_form_template_attribute")
                            .addInclude("scgk_record_form_template_attribute_listing")
                            .addInclude("scgk_record_form_template_instance")
                            .addInclude("scgk_record_form_template_instance_attribute")
                            .addInclude("scgk_record_form_template_instance_attribute_listing")
                            .addTablePrefix("scgk_");    // 设置过滤表前缀，（如果表名为t_user，则可以过滤掉t_，生成User）
                }).templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();
    }

}
